<?php
/**
 * Created by PhpStorm.
 * User: krystal
 * Date: 2019/4/23
 * Time: 13:44
 */

namespace app\common\model;


class ZhunleUserBindAlipay extends Base
{
    protected $table = 'wechat_backup_07_18_14_43_00.zhunle_user_bind_alipay';

    public function saveAli($data = [])
    {
        try
        {
            $data = $this->save($data);
        }
        catch (\Exception $e)
        {
            $this->error = '支付宝绑定失败';
            return false;
        }

        return $data;
    }

    /**
     * 获取支付宝绑定信息
     * @param $uid
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getAliNumberInfo($uid)
    {
        $aliNumberInfo = $this->where('uid', $uid)
            ->field('truename,alipay_account')
            ->find();

        if ($aliNumberInfo == null || empty($aliNumberInfo))
        {
            $result = [
                'truename' => '',
                'alipay_account' => ''
            ];
        } else
        {
            $result = [
                'truename' => $aliNumberInfo['truename'],
                'alipay_account' => $aliNumberInfo['alipay_account']
            ];
        }

        return $result;
    }
}
